import BuffUtil from '@/BuffUtil';
import BuffCommon from 'code/Core/Common/BuffCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 狂暴姿态
 **/
export default class ZS_FuryPos extends AbilityBase {
    static instance: ZS_FuryPos;
    buffType: AppBuffType = {
        id: 'buff_ZS_FuryPos',
        art: this.art,
        name: this.abilityName,
        ubertip: '降低基础攻击间隔，提升法术穿透，但是onTakeDamage增加',
        attribute: {
            物理伤害减免: -0.35,
            法术伤害减免: -0.35,
        },
    };
    constructor(id: string = 'Akbt') {
        super(id);
        ZS_FuryPos.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {
        BuffUtil.registerBuffType(this.buffType);
    }
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        // BuffUtil.clearUnitBuff(source, 'buff_zs_kuangbaozitai');
        // BuffUtil.clearUnitBuff(source, 'buff_zs_zhandouzitai');
        if (BuffUtil.hasUnitBuff(source, this.buffType.id, source)) {
            BuffUtil.clearUnitBuff(source, this.buffType.id, source);
        } else {
            // let buff = BuffUtil.addBuff(source, this.buffType.id, source);
            let lv = this.getAbilityLevel(source);
            // buff.attribute.damage_cool = -0.1 - 0.15 * lv;
            // buff.attribute.法术伤害穿透百分比 = 0.15 + 0.05 * lv;
            BuffCommon.addBuff({
                target: source,
                caster: source,
                buffTypeId: this.buffType.id,
                ablityId: this.id,
                attribute: { damage_cool: -0.1 - 0.15 * lv, 法术伤害穿透百分比: 0.15 + 0.05 * lv },
            });
        }
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
}
